home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / New System Software Extensions / OpenDoc A6 / OpenDoc Parts Framework / OPF / Examples / Text / Include / GrfxRun.h < prev    next >
Encoding:
Text File  |  1994-04-21  |  3.6 KB  |  133 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                            GrfxRun.h
  4. //    Release Version:    $ 1.0d1 $
  5. //
  6. //    Author:                        Anthone Burbidge
  7. //    Creation Date:        3/28/94
  8. //
  9. //    Copyright:    © 1993, 1994 by Apple Computer, Inc., all rights reserved.
  10. //
  11. //========================================================================================
  12.  
  13. #ifndef _GRFXRUN_
  14. #define _GRFXRUN_
  15.  
  16. #ifndef _QDFIX_
  17. #include <QDFix.h>
  18. #endif
  19.  
  20. // ----- Textension Includes -----
  21.  
  22. #ifndef _ToolBoxDump_
  23. #include "ToolBoxDump.h"
  24. #endif
  25.  
  26. #ifndef _TextensionCommon_
  27. #include "TextensionCommon.h"
  28. #endif
  29.  
  30. #ifndef _RunObject_
  31. #include "RunObject.h"
  32. #endif
  33.  
  34. //========================================================================================
  35. // CLASS CBetterGraphicsRun
  36. //========================================================================================
  37.  
  38. class    CBetterGraphicsRun    :    public CRunObject
  39. {
  40. //------------------------------------------------------------------------------
  41. //    • Constants
  42. //
  43. public:
  44.     enum { kDefaultSelectionWidth = 2,
  45.            kDefaultHite = 16,
  46.            kDefaultWidth = 16 };
  47.     
  48. //------------------------------------------------------------------------------
  49. //    • Initialization/Destruction
  50. //
  51. public:
  52.     CBetterGraphicsRun();
  53.     virtual ~CBetterGraphicsRun();
  54.     void InitBetterGraphicsRun(short selectionWidth = kDefaultSelectionWidth);
  55.  
  56. //------------------------------------------------------------------------------
  57. //    • Inherited API
  58. //
  59.     virtual CAttrObject* CreateNew() const = 0;
  60.  
  61.     virtual ClassId GetClassId() const = 0;
  62.     
  63.     Boolean IsTextRun() const;
  64.     
  65.     virtual TObjFlags GetObjFlags();
  66.     
  67.     //DoPixel2Char and DoChar2Pixel will never be called since kIndivisibleRun is returned, but they are pure virtual fns
  68.     virtual void DoPixel2Char(Pixel2CharPb* paramPb);
  69.     virtual short DoChar2Pixel(Char2PixelPb* paramPb);
  70.  
  71.     virtual Fixed DoMeasure(MeasurePb* paramPb);
  72.     virtual StyledLineBreakCode DoBreak(LineBreakPb* paramPb);
  73.     virtual void DoDrawJust(DrawJustPb* paramPb);
  74.  
  75.     virtual void SetHilite(char oldHilite, char newHilite, const RunPositionPB* paramPb, Boolean doDraw = true);
  76.     //paramPb is defined <==> doDraw == true
  77.  
  78.     virtual void DrawSelection(char hiliteStat, const RunPositionPB* paramPb);
  79.     
  80.     virtual void SetCursor(Point, const RunPositionPB*) const; //set it to arrow
  81.     
  82. protected:
  83.     virtual void CalcHiteInfo(short* ascent, short* descent, short* leading);
  84.     
  85. //------------------------------------------------------------------------------
  86. //    • New API
  87. //
  88. public:
  89.     short GetSelectionWidth() const;
  90.     virtual void SetSelectionWidth(short width);
  91.  
  92. protected:
  93.     virtual Boolean GetDimensions(short* hite, short* width) = 0;
  94.         //returns the non scaled dimensions
  95.  
  96. #ifdef txtnScal
  97.     void GetScaledDimensions(short* hite, short* width,
  98.                              const Point* numer=nil, const Point* denom=nil);
  99. #else
  100.     void GetScaledDimensions(short* hite, short* width);
  101. #endif
  102.  
  103.     virtual void Draw(const Rect* theRect) = 0;
  104.     
  105.     void GetObjectRect(const RunPositionPB* paramPb, Rect* objRect);
  106.  
  107. private:    
  108. #ifdef txtnScal
  109.     void AdjustObjRect(Rect* objRect, Point numer, Point denom);
  110. #else
  111.     void AdjustObjRect(Rect* objRect);
  112. #endif
  113.  
  114. //------------------------------------------------------------------------------
  115. //    • Data Members
  116. //
  117. private:
  118.     short fExtraWidth;
  119.     short fSelectionWidth;
  120.  
  121. };
  122.  
  123. //----------------------------------------------------------------------------------------
  124. // CBetterGraphicsRun::GetSelectionWidth
  125. //----------------------------------------------------------------------------------------
  126.  
  127. inline short CBetterGraphicsRun::GetSelectionWidth() const
  128. {
  129.     return fSelectionWidth;
  130. }
  131.  
  132. #endif
  133.